package com.example.course.router;

import com.example.course.bean.Course;
import com.example.course.bean.Student;
import com.example.course.bean.Teacher;
import com.example.course.service.CourseService;
import com.example.course.service.StudentService;
import com.example.course.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PageRouter {
    @Autowired
    private StudentService studentService;
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private CourseService courseService;
    @RequestMapping("/course/schoolPage")
    public String schoolPage(){
        return "/page/admin/school";
    }
    @RequestMapping("/course/studentPage")
    public String studentPage(){
        return "page/admin/student";
    }
    @RequestMapping("/course/coursePage")
    public String coursePage(){
        return "page/admin/course";
    }
    @RequestMapping("/course/studentAddPage")
    public String studentAddPage(){
        return "/page/admin/studentAdd";
    }
    @RequestMapping("/course/courseAddPage")
    public String courseAddPage(){
        return "/page/teacher/courseAdd";
    }
    @RequestMapping("/course/teacherAddPage")
    public String teacherAddPage(){
        return "/page/admin/teacherAdd";
    }
    @RequestMapping("/course/studentUpPage/{id}")
    public String studentUpPage(@PathVariable Integer id, Model model){
        Student student = studentService.getStudentByStudentId(id);
        model.addAttribute("student",student);
        return "/page/admin/studentUp";
    }@RequestMapping("/course/courseUpPage/{id}")
    public String courseUpPage(@PathVariable Integer id, Model model){
        Course courseById = courseService.getCourseById(id);
        model.addAttribute("course",courseById);
        return "/page/admin/courseUp";
    }
    @RequestMapping("/course/teaCourseUpPage/{id}")
    public String teaCourseUpPage(@PathVariable Integer id, Model model){
        Course courseById = courseService.getCourseById(id);
        model.addAttribute("course",courseById);
        return "/page/teacher/courseUp";
    }
    @RequestMapping("/course/teacherUpPage/{id}")
    public String teacherUpPage(@PathVariable Integer id, Model model){
        Teacher teacherById = teacherService.getTeacherById(id);
        model.addAttribute("teacher",teacherById);
        return "/page/admin/teacherUp";
    }
    @RequestMapping("/course/teacherPage")
    public String teacherPage(){
        return "page/admin/teacher";
    }
    @RequestMapping("/course/teaCoursePage")
    public String teaCoursePage(){
        return "page/teacher/course";
    }
    @RequestMapping("/course/teaCourseAddPage")
    public String teaCourseAddPage(){
        return "page/teacher/courseAdd";
    }
    @RequestMapping("/course/studentCoursePage")
    public String studentCoursePage(){
        return "page/student/studentCourse";
    }
    @RequestMapping("/course/studentChooseCourse")
    public String studentChooseCourse(){
        return "page/student/studentChooseCourse";
    }
    @RequestMapping("/course/toRegister")
    public String toRegister(){
        return "register";
    }
    @RequestMapping("/course/accountRule")
    public String accountRule(){
        return "page/admin/accountRule";
    }
}
